// pages/mine/events/events.js
import {
    HTTP
} from '../../../utils/http.js'
let ajax = new HTTP()

Page({
    data: {
        eventsArr: [],
        loading: false
    },
    onLoad(options) {
        wx.showLoading({
            title: '加载中',
        })
        let memberid = wx.getStorageSync("memberid")
        this._getMysportList(memberid)
    },
    onEventsTap(event) {
        let postId = event.currentTarget.dataset.eventsid
        let postTitle = event.currentTarget.dataset.eventstitle
        wx.navigateTo({
            url: '/pages/find/apply/apply?id=' + postId + '&title=' + postTitle,
        })
    },
    // 我的赛事报名列表
    _getMysportList(memberid) {
        ajax.request({
            method: "GET",
            url: "mycenter",
            data: {
                actname: 'mysport',
                memberid: memberid
            },
            success: (res) => {
                wx.hideLoading()
                if (res.rescode == "0000") {
                    this.setData({
                        loading: true,
                        eventsArr: res.data
                    })
                } else {
                    this.setData({
                        loading: true,
                        eventsArr: []
                    })
                }
            }
        })
    },
})